package poc.myrun;

import org.docx4j.TextUtils;
import org.docx4j.XmlUtils;
import org.docx4j.wml.P;
import org.docx4j.wml.R;
import poc.utils.RunUtil;

/**
 * Created by zhangleilei on 2018/10/11.
 */
public class MyRun {
    public R run;
    public String cValue;
    public MyRun(R run){
        this.run=run;
        this.cValue= TextUtils.getText(run);
    }
    public String getLeftStr(String engSnippet,String eValue){
        int value_index = engSnippet.indexOf(eValue);
        return engSnippet.substring(0,value_index);
    }
    public void addRun(P p, String eValue){
        RunUtil.setRunText(this.run,eValue);
        p.getContent().add(this.run);
    }
    public String  getRightStr(String engSnippet,String eValue){
        int value_index = engSnippet.indexOf(eValue);
        return engSnippet.substring(value_index+eValue.length());
    }
    public boolean find(String engSnippet,String eValue){
//        System.out.println("engSnippet="+engSnippet +"   eValue="+eValue);
        return engSnippet.indexOf(eValue) !=-1;
    }
}
